package org.southyin.commons;

/**
 * @param <T>
 * @ClassName CommonsResp
 * @Description TODO
 * @Author hasee
 * @Date 2021/10/27
 * @Version 1.0
 **/
public class CommonsResp<T> {

    private Integer code;
    private String msg;
    private T data;

    public static <T> CommonsResp<T> success(Integer code, String msg, T data){
        return new CommonsResp(code,msg,data);
    }

    public static <T> CommonsResp<T> success(Integer code, String msg){
        return new CommonsResp(code,msg,null);
    }

    public static <T> CommonsResp<T> success(){
        return new CommonsResp(RespEnum.SUCCESS.getCode(),RespEnum.SUCCESS.getMsg(),null);
    }

    public static <T> CommonsResp<T> success(T data){
        return new CommonsResp(RespEnum.SUCCESS.getCode(),RespEnum.SUCCESS.getMsg(),data);
    }

    public static <T> CommonsResp<T> failed(Integer code, String msg, T data){
        return new CommonsResp(code,msg,data);
    }

    public static <T> CommonsResp<T> failed(Integer code, String msg){
        return new CommonsResp(code,msg,null);
    }

    public static <T> CommonsResp<T> failed(){
        return new CommonsResp(RespEnum.FAILED.getCode(),RespEnum.FAILED.getMsg(),null);
    }

    public static <T> CommonsResp<T> failed(T data){
        return new CommonsResp(RespEnum.FAILED.getCode(),RespEnum.FAILED.getMsg(),data);
    }

    public CommonsResp() {}
    public CommonsResp(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
